
using System;
using System.Timers;
using Paret;
using Gtk;
using System.Collections.Generic;

namespace Paret
{
	
	public class ParetTimer
	{
		int ellapsed;
		Timer changeparet;
		GconfParet paretconf;
		Papers papers;
		
		public ParetTimer(int ellapsed)
		{
			this.ellapsed = ellapsed;
			this.changeparet = new Timer();
			paretconf = new GconfParet();
			changeparet.Elapsed += new ElapsedEventHandler( elapseNotifier); 

		}
		
		public int Ellapsed
		{
			get {
				return ellapsed;
			}
			set {
				ellapsed = value;
			}
		}
		
		public void start(Papers papers){
			this.papers = papers;
			changeparet.Interval = ellapsed * 1000 * 60;
			paretconf.updateGConf(nextOne());
			changeparet.Start();

		}
		
		public void stop(){
			changeparet.Stop();
		}
		
		private void elapseNotifier( object o, ElapsedEventArgs e)
		{
			paretconf.updateGConf(nextOne());
		}
		
		private string nextOne()
		{
			return papers.getNextPaper();
			
		}
		
				
	}
}
